package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.common.ResponseData;
import com.gxa.pojo.Emp;
import com.gxa.service.EmpService;
import com.gxa.utils.DateUtils;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Api(value = "员工管理",tags = "员工管理接口API")
@RequestMapping(value = "/emp")
public class EmpController {
        //qqqqw
    @Autowired
    private EmpService empService;


    /**
     * 查询全部员工基本信息
     * @param page 当前页码数
     * @param limit 每页显示条数
     * @return
     */
    @RequestMapping(value = "/queryAll" , method = RequestMethod.GET)   //接口和前端传递数据方式
    @ApiOperation(value = "查询全部员工接口",notes = "查询员工基本信息",httpMethod = "GET", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "limit",value = "每页显示条数",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R queryAll(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit){
        R r = new R();
        Integer param1 =(page -1)*limit;
        Integer param2 = limit;
        List<Emp> empList =new ArrayList<>();
        Emp emp1 = new Emp();
        emp1.setEmp_number("100");
        emp1.setEmp_name("张三");
        emp1.setEmp_sex("男");
        String emp_birthday = "1998-12-21";
        emp1.setEmp_education(1);
        emp1.setEmp_phone("15884559982");
        emp1.setEmp_dept("");
        emp1.setEmp_pic("src/imgs1");
        emp1.setEmp_jointb("111");
        emp1.setEmp_departuretb("222");
        emp1.setEmp_joindeparturesta(1);
        empList.add(emp1);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(empList);
        return r;
//        return empService.queryAll(page,limit);
    }



    /**
     * 查询在职员工信息
     * @param page 当前页码数
     * @param limit 每页显示条数
     * @return
     */

    @RequestMapping(value = "/queryworking" , method = RequestMethod.GET)   //接口和前端传递数据方式
    @ApiOperation(value = "查询在职员工接口",notes = "传递在职员工基本信息",httpMethod = "GET", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "limit",value = "每页显示条数",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R queryWorking(Integer EMP_QUIT,@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit){
        R r = new R();
        Integer param1 =(page -1)*limit;
        Integer param2 = limit;
        List<Emp> empList2 =new ArrayList<>();
        Emp emp2 = new Emp();
        emp2.setEmp_number("111");
        emp2.setEmp_name("李四");
        emp2.setEmp_sex("男");
        String emp_birthday = "1997-12-21";
        emp2.setEmp_birthday(DateUtils.string2Date(emp_birthday));
        emp2.setEmp_education(1);
        emp2.setEmp_phone("15894559982");
        emp2.setEmp_dept("");
        emp2.setEmp_level("高级");
        emp2.setEmp_jointb("123");
        emp2.setEmp_idcard("511621199987656721");
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(emp2);
        return r;
    }


    /**
     * 录入员工信息
     * @return
     */
    @RequestMapping(value = "/addEmp" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "录入员工接口",notes = "录入员工基本信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiImplicitParams({
            @ApiImplicitParam(name = "emp_joinDepartureSta",value = "入离职状态",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_maritalStatus",value = "婚姻状况",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_education",value = "学历",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_bloodType",value = "血型",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_nation",value = "民族",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_dept",value = "所在部门",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_job",value = "职务",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_title",value = "职称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_category",value = "人员类别",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R addEmp(Emp emp){
        R r = new R();
        Emp emp1 = new Emp();
        Map<String,List<Emp>> empMap = new HashMap<>();
        List<Emp> empList =new ArrayList<>();
//        return empService.addEmp(emp1);

        r.setCode(200);
        r.setMsg("录入成功");
//        r.setData(emp3);
        return r;
    }


    /**
     * 导入员工信息
     * @return
     */

    @RequestMapping(value = "/importEmp" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "导入员工接口",notes = "导入员工信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R importEmp(){
        R r = new R();

        r.setCode(200);
        r.setMsg("导入成功");
        return r;
    }


    /**
     * 导出员工信息
     * @return
     */


    @RequestMapping(value = "/exportEmp" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "导出员工接口",notes = "导出员工信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R exportEmp(){
        R r = new R();
        r.setCode(200);
        r.setMsg("导出成功");
        return r;
    }


    /**
     * 编辑员工信息
     * @param  emp 员工对象
     * @return
     */

    @RequestMapping(value = "/editEmp" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "编辑员工接口",notes = "编辑员工信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R editEmp(Emp emp){
        R r = new R();
        r.setCode(200);
        r.setMsg("更改成功");
        return r;
    }

    /**
     * 更改员工状态为离职
     * @param emp_joinDepartureSta 入离职状态
     * @return
     */

    @RequestMapping(value = "/setWorkingToDeparture" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "将在职员工改为离职接口",notes = "在职变离职",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R setWorkingToDeparture(Integer emp_joinDepartureSta){
        R r = new R();
        r.setCode(200);
        r.setMsg("离职成功");
        return r;
    }


    /**
     * 更改员工状态为拉黑
     * @param emp_joinDepartureSta 入离职状态
     * @return
     */


    @RequestMapping(value = "/setDepartureToBlackList" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "将离职员工拉黑接口",notes = "离职变为黑名单",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R setDepartureToBlackList(Integer emp_joinDepartureSta){
        R r = new R();
        r.setCode(200);
        r.setMsg("拉黑成功");
        return r;
    }


    /**
     * 更改员工状态为从拉黑为离职
     * @param emp_joinDepartureSta 入离职状态
     * @return
     */


    @RequestMapping(value = "/setBlackListToDeparture" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "将离职员工取消拉黑接口",notes = "黑名单人员变离职人员",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R setBlackListToDeparture(Integer emp_joinDepartureSta){
        R r = new R();
        Emp emp = new Emp();
        emp.setEmp_number("1559");
        emp.setEmp_joindeparturesta(1);
        r.setCode(200);
        r.setData(emp);
        r.setMsg("取消拉黑成功");
        return r;
    }

    /**
     * 查看员工详细信息
     * @param emp
     * @return
     */

    @RequestMapping(value = "/queryEmpDetails" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "员工详情接口",notes = "查看员工详情",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R queryEmpDetails(Emp emp){
        R r = new R();
        Emp emp1 = new Emp();
        r.setCode(200);
        r.setMsg("查看成功");
        r.setData(emp1);
        return r;
    }

}
